# -*- coding: utf-8 -*- 
# 作者:飞虎
# 开发时间:2022/5/15 20:11
from PyQt5.Qt import *


class Window(QWidget):
	def __init__(self):
		super().__init__()
		self.setWindowTitle('QProgressBar学习')
		self.resize(500, 500)
		self.setup_ui()

	def setup_ui(self):
		pb=QProgressBar(self)
		pb.resize(400,40)


		print(pb.minimum())
		print(pb.maximum())

		# pb.setRange(0,100)

		pb.setMinimum(0)
		pb.setValue(20)

		# pb.setFormat('当前人数/总人数 %p%')
		# pb.setFormat('当前人数%v/总人数 %m')

		# pb.reset()

		btn = QPushButton(self)
		btn.setText('测试按钮')
		btn.move(200,200)

		def test():
			# pb.resetFormat()
			# pb.setAlignment(Qt.AlignHCenter)
			# print(pb.text())
			pb.setOrientation(Qt.Vertical)
			pb.resize(40,400)
			print(pb.isTextVisible())
			pb.setTextDirection(QProgressBar.TopToBottom)
			pb.setInvertedAppearance(True)

		btn.clicked.connect(test)
		# pb.setInvertedAppearance(True)

		timer = QTimer(pb)
		def change_progress():
			# print('xxx')
			if pb.value() == pb.maximum():
				timer.stop()
			pb.setValue(pb.value()+1)
			pass

		timer.timeout.connect(change_progress)
		timer.start(1000)
		pb.valueChanged.connect(lambda val:print('当前的进度值为:',val))

	# pb.setTextVisible(False)


if __name__ == '__main__':
	import sys

	app = QApplication(sys.argv)
	window = Window()
	window.show()
	sys.exit(app.exec_())